﻿@using NTQOnlineExam.Services.Infrastructure.MVC
@model NTQOnlineExamFrontend.Models.BasketViewModel

@{
    ViewBag.Title = "Shopping Basket";
    Layout = "~/Views/Shared/_LayoutNoLeft.cshtml";
}

<table class="table table-bordered" id="checkoutlist">
    <thead>
        <tr>
            <th>@this.LocalResources("TermId")</th>
            <th>@this.LocalResources("TermName")</th>
            <th>@this.LocalResources("Price")</th>
            <th>@this.LocalResources("Comment")</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @if (Model.BasketItems != null)
        {
            foreach (var item in Model.BasketItems)
            {
            <tr id="@item.Id">
                <td>@item.TermId</td>
                <td>@item.TermName</td>
                <td>@item.Price.ToString("#.## AUD")</td>
                <td>@item.Comment</td>
                <td><a onclick="BasketClient.RemoveItemFromBasket('@item.Id') ">Remove</a></td>
            </tr>
            }
        }


    </tbody>
</table>
<ul class="text-right shopping-cart  checkout">
    <li><strong>Total Price</strong>:<span id="totalPrice"> @Model.TotalPrice.ToString("#.## AUD")</span></li>
    @*<li><strong>Shipping</strong>: Free</li>*@
    @if (Model.BasketItems != null && Model.BasketItems.Count > 0)
    {
        <li><a id="btnProcessCheckout"  class="btn btn-red" href='@Url.RouteUrl(new {Controller = "Basket", Action = "Checkout"})'>Proceed to checkout</a></li>
    }
    else
    {
        <li><button id="btnProcessCheckout" class="btn btn-red" disabled="disabled" type="button">Proceed to checkout</button></li>
    }
</ul>

<script type="text/javascript">

    function checkout() {
    }

    $(document).ready(function () {
        BasketClient.SetRemoveItemUrl('@Url.RouteUrl(new { Controller = "Basket", Action = "RemoveBasketItem" })');
   
    });
</script>
